/**
 * Copyright (c) 2010 Simple Graph Tools contributors. All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 *
 * $Id$
 */
package org.sgt.datamodel.impl;

import java.util.Map;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EFactoryImpl;
import org.eclipse.emf.ecore.plugin.EcorePlugin;
import org.sgt.datamodel.Action;
import org.sgt.datamodel.ActionParameter;
import org.sgt.datamodel.ActionParameterKind;
import org.sgt.datamodel.ActionSpecification;
import org.sgt.datamodel.BehaviorSpecification;
import org.sgt.datamodel.CreateSpecification;
import org.sgt.datamodel.DataStore;
import org.sgt.datamodel.DatamodelFactory;
import org.sgt.datamodel.DatamodelPackage;
import org.sgt.datamodel.DeleteSpecification;
import org.sgt.datamodel.Executor;
import org.sgt.datamodel.MultiPrimitive;
import org.sgt.datamodel.MultiReference;
import org.sgt.datamodel.Primitive;
import org.sgt.datamodel.QuerySpecification;
import org.sgt.datamodel.Reference;
import org.sgt.datamodel.UpdateSpecification;
import org.sgt.datamodel.Value;
import org.sgt.datamodel.util.ExecutionException;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class DatamodelFactoryImpl extends EFactoryImpl implements DatamodelFactory {
	/**
	 * Creates the default factory implementation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static DatamodelFactory init() {
		try {
			DatamodelFactory theDatamodelFactory = (DatamodelFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.sgt.org/datamodel/1.0.0/datamodel.ecore"); 
			if (theDatamodelFactory != null) {
				return theDatamodelFactory;
			}
		}
		catch (Exception exception) {
			EcorePlugin.INSTANCE.log(exception);
		}
		return new DatamodelFactoryImpl();
	}

	/**
	 * Creates an instance of the factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DatamodelFactoryImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EObject create(EClass eClass) {
		switch (eClass.getClassifierID()) {
			case DatamodelPackage.CONTAINER: return createContainer();
			case DatamodelPackage.ACTION_SPECIFICATION: return createActionSpecification();
			case DatamodelPackage.ACTION: return createAction();
			case DatamodelPackage.VALUE_MAP: return (EObject)createValueMap();
			case DatamodelPackage.REFERENCE: return createReference();
			case DatamodelPackage.PRIMITIVE: return createPrimitive();
			case DatamodelPackage.BEHAVIOR_SPECIFICATION: return createBehaviorSpecification();
			case DatamodelPackage.ACTION_PARAMETER: return createActionParameter();
			case DatamodelPackage.MULTI_REFERENCE: return createMultiReference();
			case DatamodelPackage.MULTI_PRIMITIVE: return createMultiPrimitive();
			case DatamodelPackage.EXECUTOR: return createExecutor();
			case DatamodelPackage.CREATE_SPECIFICATION: return createCreateSpecification();
			case DatamodelPackage.UPDATE_SPECIFICATION: return createUpdateSpecification();
			case DatamodelPackage.QUERY_SPECIFICATION: return createQuerySpecification();
			case DatamodelPackage.DELETE_SPECIFICATION: return createDeleteSpecification();
			case DatamodelPackage.DATA_STORE: return createDataStore();
			case DatamodelPackage.EOBJECT_MAP: return (EObject)createEObjectMap();
			default:
				throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object createFromString(EDataType eDataType, String initialValue) {
		switch (eDataType.getClassifierID()) {
			case DatamodelPackage.ACTION_PARAMETER_KIND:
				return createActionParameterKindFromString(eDataType, initialValue);
			case DatamodelPackage.EXECUTION_EXCEPTION:
				return createExecutionExceptionFromString(eDataType, initialValue);
			default:
				throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String convertToString(EDataType eDataType, Object instanceValue) {
		switch (eDataType.getClassifierID()) {
			case DatamodelPackage.ACTION_PARAMETER_KIND:
				return convertActionParameterKindToString(eDataType, instanceValue);
			case DatamodelPackage.EXECUTION_EXCEPTION:
				return convertExecutionExceptionToString(eDataType, instanceValue);
			default:
				throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public org.sgt.datamodel.Container createContainer() {
		ContainerImpl container = new ContainerImpl();
		return container;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ActionSpecification createActionSpecification() {
		ActionSpecificationImpl actionSpecification = new ActionSpecificationImpl();
		return actionSpecification;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Action createAction() {
		ActionImpl action = new ActionImpl();
		return action;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Map.Entry<String, Value> createValueMap() {
		ValueMapImpl valueMap = new ValueMapImpl();
		return valueMap;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Reference createReference() {
		ReferenceImpl reference = new ReferenceImpl();
		return reference;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Primitive createPrimitive() {
		PrimitiveImpl primitive = new PrimitiveImpl();
		return primitive;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BehaviorSpecification createBehaviorSpecification() {
		BehaviorSpecificationImpl behaviorSpecification = new BehaviorSpecificationImpl();
		return behaviorSpecification;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ActionParameter createActionParameter() {
		ActionParameterImpl actionParameter = new ActionParameterImpl();
		return actionParameter;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MultiReference createMultiReference() {
		MultiReferenceImpl multiReference = new MultiReferenceImpl();
		return multiReference;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MultiPrimitive createMultiPrimitive() {
		MultiPrimitiveImpl multiPrimitive = new MultiPrimitiveImpl();
		return multiPrimitive;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Executor createExecutor() {
		ExecutorImpl executor = new ExecutorImpl();
		return executor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public CreateSpecification createCreateSpecification() {
		CreateSpecificationImpl createSpecification = new CreateSpecificationImpl();
		return createSpecification;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public UpdateSpecification createUpdateSpecification() {
		UpdateSpecificationImpl updateSpecification = new UpdateSpecificationImpl();
		return updateSpecification;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public QuerySpecification createQuerySpecification() {
		QuerySpecificationImpl querySpecification = new QuerySpecificationImpl();
		return querySpecification;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DeleteSpecification createDeleteSpecification() {
		DeleteSpecificationImpl deleteSpecification = new DeleteSpecificationImpl();
		return deleteSpecification;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DataStore createDataStore() {
		DataStoreImpl dataStore = new DataStoreImpl();
		return dataStore;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Map.Entry<String, EList<EObject>> createEObjectMap() {
		EObjectMapImpl eObjectMap = new EObjectMapImpl();
		return eObjectMap;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ActionParameterKind createActionParameterKindFromString(EDataType eDataType, String initialValue) {
		ActionParameterKind result = ActionParameterKind.get(initialValue);
		if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertActionParameterKindToString(EDataType eDataType, Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ExecutionException createExecutionExceptionFromString(EDataType eDataType, String initialValue) {
		return (ExecutionException)super.createFromString(eDataType, initialValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertExecutionExceptionToString(EDataType eDataType, Object instanceValue) {
		return super.convertToString(eDataType, instanceValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DatamodelPackage getDatamodelPackage() {
		return (DatamodelPackage)getEPackage();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @deprecated
	 * @generated
	 */
	@Deprecated
	public static DatamodelPackage getPackage() {
		return DatamodelPackage.eINSTANCE;
	}

} //DatamodelFactoryImpl
